<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/common/head.jsp"%>
    <div class="container mt-5">
        <div class="row tm-content-row">
            <div class="col-sm-12 col-md-12 col-lg-8 col-xl-12 tm-block-col">
                <div class="tm-bg-primary-dark tm-block tm-block-products">
                    <h3 style="color: white">合同列表</h3>
                    <div class="tm-product-table-container">
                        <div class="">
                            <a href="accounts1/add-accounts1.do"
                                    class="btn btn-primary btn-block text-uppercase mb-3 w-25 fa-pull-right">添加合同</a>
                            <form method="post" action="${pageContext.request.contextPath }/accounts1/accounts1.do">
                                <input name="queryname" value="${queryUserName }" placeholder="请输入合同关键字"  class="form-control  w-25" style="float: left;">
                                <div id="s1" style="float: left;">企业名称：</div>
                                <select name="queryUserRole" class="custom-select w-25" style="float:left" >
                                    <c:if test="${accList != null }">
                                        <option value="0">--请选择--</option>
                                        <c:forEach var="role" items="${accList}">
                                            <option <c:if test="${role.a_id == queryUserRole }">selected="selected"</c:if>
                                                    value="${role.a_id}">${role.roleName}</option>
                                        </c:forEach>
                                    </c:if>
                                </select>
                                <input type="hidden" name="pageIndex" value="1"/>
                                <input	class="btn btn-info" value="查 询" type="submit" id="searchbutton">
                            </form>
                        </div>
                        <table class="table table-hover tm-table-small tm-product-table">
                            <thead>
                            <tr>
                                <th scope="col">&nbsp;</th>
                                <th scope="col">合同标题</th>
                                <th scope="col">企业名称</th>
                                <th scope="col">合同编号</th>
                                <th scope="col">合同金额</th>
                                <th scope="col">已回金额</th>
                                <th scope="col">签订人</th>
                                <th scope="col">签订日期</th>
                                <th scope="col">状态</th>
                                <th scope="col">修改</th>
                                <th scope="col">删除</th>
                                <th scope="col">&nbsp;</th>

                            </tr>
                            </thead>

                            <c:forEach var="acc" items="${accounts1 }" varStatus="status">
                            <tbody>
                                <tr>
                                    <th scope="row"><input type="checkbox" name="t_id" value="${acc.t_id}"/></th>
                                <td>
                                    <span>${acc.t_title}</span>
                                </td>
                                <td>
                                    <span>${acc.e_name}</span>
                                </td>
                                <td>
                                    <span>${acc.t_no}</span>
                                </td>
                                <td>
                                    <span>${acc.t_amount}</span>
                                </td>
                                <td>
                                    <span>${acc.t_bamount}</span>
                                </td>
                                <td>
                                    <span>${acc.t_person}</span>
                                </td>
                                <td>
                                   <span>
					                <fmt:formatDate value="${acc.t_sdate}" pattern="yyyy-MM-dd"/>
					                </span>
                                </td>
                                <td>
                                    <span>
                                        <c:if test="${acc.t_state==1}">未签</c:if>
                                        <c:if test="${acc.t_state==2}">已签</c:if>
                                    </span>

                                </td>
                                    <td>
                                        <button type="button" class="tm-product-delete-link modify" data-toggle="modal" data-target="#myModal"  >
                                            <i class="far fa fa-edit tm-product-delete-icon" t_id="${acc.t_id}"></i>
                                        </button>
                                        <div class="modal fade bs-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="top:210px" >
                                            <div class="modal-dialog" role="document">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <h4 class="modal-title" id="myModalLabel">合同修改框</h4>
                                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                    </div>
                                                    <form action="${pageContext.request.contextPath }/accounts1/update.do" method="post">
                                                        <div class="modal-body">
                                                            <table style="text-align: left;margin-left: 80px">
                                                                <input type="hidden" id="d" name="t_id" required>
                                                                <tr>
                                                                    <td>合同标题:</td>
                                                                    <td><input type="text" name="t_title" id="t_title" value="" required></td>
                                                                    <td></td>
                                                                </tr>
                                                                <tr>
                                                                    <td>合同编号:</td>
                                                                    <td><input type="text" name="t_no" id="t_no" value="" required></td>
                                                                    <td></td>
                                                                </tr>
                                                                <tr>
                                                                    <td>已回金额:</td>
                                                                    <td><input type="text" name="t_bamount" id="t_bamount" value="" required></td>
                                                                    <td></td>
                                                                </tr>
                                                            </table>
                                                        </div>
                                                        <div class="modal-footer">
                                                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                                            <button type="submit" class="btn btn-primary">确定</button>
                                                        </div>
                                                    </form >
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <a href="accounts1/delAcc.do?t_id=${acc.t_id}" class="tm-product-delete-link"  onclick="return confirmDel()" >
                                            <i class="far fa-trash-alt tm-product-delete-icon"></i>
                                        </a>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                    </div>
                    <!-- table container -->
                    <div >
                        <ul class="page-num-ul clearfix" style="float: left" >
                            <input type="hidden" id="totalPageCount" value="${totalPageCount}"/>
                            <c:import url="rollpage.jsp">
                                <c:param name="totalCount" value="${totalCount}"/>
                                <c:param name="currentPageNo" value="${currentPageNo}"/>
                                <c:param name="totalPageCount" value="${totalPageCount}"/>
                            </c:import>
                        </ul>
                        <button id="del" class="btn btn-primary btn-block text-uppercase w-25 fa-pull-right" style="float: right">
                            删除所选
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

<%@ include file="/WEB-INF/jsp/common/foot.jsp" %>
<script src="${pageContext.request.contextPath }/js/accounts1.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-3.3.1.min.js"></script>
<script>
    function confirmDel()
    {
        if(confirm("确定删除?")){
           return true;
        }else{
            return false;
        }
    }

    $("#del").click(function () {
        var oid=document.getElementsByName("t_id");
        var ids="";
        var n=0;
        for (var i=0;i<oid.length;i++){
           if(oid[i].checked==true){
               var id=oid[i].value;
               alert(id)
               if(n==0){
                   ids+="ids="+id;
               }else{
                   ids+="&ids="+id;
               }
               n++;
           }
        }
       $.get("/SSM/accounts1/del.do",ids,function(data){
            if(data="\"ok\""){
                alert("删除成功!");
                location.href="accounts1/accounts1.do";
            }else{
                alert("删除失败!");
            }
        });
    });


</script>


